﻿using DiscreteMath.Tests;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System.Web.Routing;
using System.Threading.Tasks;

namespace DiscreteMath.WebApp
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Task.Delay(5000).ContinueWith((Task t) =>
            {
                var machine = AutomataFactory.Factory.ContainsEitherBBorBAB;
                var text = Newtonsoft.Json.JsonConvert.SerializeObject(machine.Device);//JsonConverter.ToJson(machine.Device);
				
                var hub = GlobalHost.ConnectionManager.GetHubContext<Dispatcher>();
                hub.Clients.All.updatedMachine(machine.Device);
            });
            

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}